﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GAtividade.aspx.cs" Inherits="crm.aplicacao.CRMSystem.GAtividade"
    MasterPageFile="~/CRM.Master" %>

<%@ Register Assembly="Ext.Net.UX" Namespace="Ext.Net.UX" TagPrefix="ux" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
 <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javascript">
    var template = '<span style="color:{0};">{1}</span>';
    var data = new Date();
    var data_1 = data.getdate();
    var dataretorno = function (value) {
        return string.format(template, (value < agora) ? "black" : "red", agora);

    };
    </script>
    <ext:Store ID="strEmpresas" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="idempresas">
                <Fields>
                    <ext:RecordField Name="idempresas" />
                    <ext:RecordField Name="empresa" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
       <ext:Store ID="strUsuario" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="idusuarios">
                <Fields>
                    <ext:RecordField Name="idusuarios" />
                    <ext:RecordField Name="nome" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="strContato" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="idcontatos">
                <Fields>
                    <ext:RecordField Name="idcontatos" />
                    <ext:RecordField Name="contato" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:GridPanel ID="GridAtividade" runat="server" Title="Gerência de Atividades" AutoScroll="true"
        AutoWidth="true" Height="900" AutoExpandColumn="empresa">
      <Store>
            <ext:Store ID="strAtividade" runat="server">
                <Reader>
                    <ext:JsonReader IDProperty="idatividade">
                        <Fields>
                            <ext:RecordField Name="idatividade" />
                            <ext:RecordField Name="empresa" />
                            <ext:RecordField Name="descricao" />
                            <ext:RecordField Name="produto" />
                            <ext:RecordField Name="dataretorno" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>

        </Store>
        <TopBar>
            <ext:Toolbar ID="ToolbarAtividade" runat="server" AutoWidth="true">
                <Items>
                    <%--<ext:Button ID="btNovaAtividade" runat="server" Text="Nova Atividade" Icon="LightningAdd">
                        <Listeners>
                            <Click Handler="#{WindowsAtividade}.show()" />
                        </Listeners>
                    </ext:Button>
                    <ext:ToolbarSeparator />--%>
                    <ext:Button ID="btRealizar" runat="server" Text="Realizar" Icon="LightningGo">
                        <Listeners>
                            <Click Handler="Ext.net.DirectMethods.realizar();" />
                        </Listeners>
                    </ext:Button>
                    <ext:ToolbarSeparator />
                    <ext:Button ID="btVisualizar" runat="server" Text="Visualizar" Icon="PageWhiteLightning">
                        <Listeners>
                            <Click Handler="Ext.net.DirectMethods.visualizarAtividade();" />
                        </Listeners>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column ColumnID="colData" Width="80px" Header="Data" DataIndex="dataretorno" >
                  <Renderer Handler="return Ext.util.Format.date(value, 'd/m/Y');" Fn="dataretorno" />
                <%--<Renderer Fn="dataretornoatividade" />--%>
              <%--  <Renderer  Format"dd-mm-yyyy"/>--%>
                </ext:Column>
                <ext:Column ColumnID="colEmpresas" Width="100px" Header="Empresas" DataIndex="empresa" />
                <ext:Column ColumnID="colProdtuo" Width="160px" Header="Produto" DataIndex="produto" />
                <ext:Column ColumnID="colAtividade" Width="620px" Header="Descrição" DataIndex="descricao" />
            </Columns>
        </ColumnModel>
        <SelectionModel>
            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
        </SelectionModel>
        <BottomBar>
            <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="20" />
        </BottomBar>
        <LoadMask ShowMask="true" />
    </ext:GridPanel>
    <%--<ext:Window ID="WindowsAtividade" runat="server" Icon="LightningAdd" Title="Nova Atividade"
        Hidden="true" Modal="true" Width="450" AutoHeight="true" Resizable="false">
        <Items>
            <ext:FormPanel ID="FormPanel1" runat="server" Padding="5" Layout="Anchor" BodyStyle="background-color: transparent;"
                Header="false">
                <Items>
                    <ext:ComboBox ID="cbEmpresa" runat="server" FieldLabel="Empresa" AllowBlank="false"
                        MsgTarget="Side" AnchorHorizontal="93%" Enabled="false" />
                    <ext:TextArea ID="txtDescricaoAtividade" runat="server" FieldLabel="Descrição" AllowBlank="false"
                        AnchorHorizontal="93%" MsgTarget="Side" />
                    <ext:DateField ID="dtRetorno" runat="server" FieldLabel="Data Retorno" AllowBlank="false"
                        MsgTarget="Side" AnchorHorizontal="50%" />
                    <ext:ComboBox ID="cbResponsavelAtividade" runat="server" FieldLabel="Responsável"
                        AnchorHorizontal="93%" AllowBlank="false" MsgTarget="Side" />
                </Items>
                <Buttons>
                    <ext:Button ID="Button1" runat="server" Text="Gravar" Icon="Disk">
                        <Listeners>
                            <Click Handler="Ext.net.DirectMethods.inserir();" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="Button2" runat="server" Text="Cancelar" Icon="Cancel">
                        <Listeners>
                            <Click Handler="#{WindowsFinalizar}.hide();" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </Items>
        <Listeners>
            <Close Handler="Ext.net.DirectMethods.limparCampo();" />
            <Hide Handler="Ext.net.DirectMethods.limparCampo();" />
        </Listeners>
    </ext:Window>--%>
    <ext:Window ID="WindowsRealizado" runat="server" Icon="LightningGo" Title="Realizado"
        Hidden="true" Modal="true" Width="450" AutoHeight="true" Resizable="false">
        <Items>
            <ext:FormPanel ID="FormPanel2" runat="server" Padding="5" Layout="Anchor" BodyStyle="background-color: transparent;"
                Header="false">
                <Items>
                    <ext:ComboBox ID="cbEmpresaRealizado" runat="server" FieldLabel="Empresa" AnchorHorizontal="95%"
                        AllowBlank="false" MsgTarget="Side" StoreID="strEmpresas" ValueField="idempresas"
                        DisplayField="empresa" />
                    <ext:TextArea ID="txtObservacao" runat="server" FieldLabel="Obervação" AllowBlank="false"
                        AnchorHorizontal="95%" MsgTarget="Side" />
                    <ext:DateField ID="dtContatoRealizado" runat="server" FieldLabel="Data Contato" AllowBlank="false"
                        AnchorHorizontal="69%" MsgTarget="Side" />
                    <ext:Checkbox ID="checkNovaAtivdade" runat="server" BoxLabel="Agendar Nova Atividade"
                        Height="30" AnchorHorizontal="95%" OnDirectCheck="Check_Clicked"  />
                    <ext:FieldSet ID="FieldSet1" runat="server" Title="Nova Atividade" Collapsible="true"
                        Layout="form">
                        <Items>
                            <ext:DateField ID="dtRetorno" runat="server" FieldLabel="Data Retorno" AllowBlank="false"
                                AnchorHorizontal="70%" MsgTarget="Side" />
                            <ext:TextArea ID="txtDescricaoNova" runat="server" FieldLabel="Descrição" AllowBlank="false"
                                AnchorHorizontal="95%" MsgTarget="Side" />
                            <ext:ComboBox ID="cbResponsavelNova" runat="server" FieldLabel="Responsável" AnchorHorizontal="95%"
                                AllowBlank="false" MsgTarget="Side"  StoreID="strUsuario" ValueField="idusuarios"
                                DisplayField="nome"/>
                        </Items>
                    </ext:FieldSet>
                </Items>
                <Buttons>
                    <ext:Button ID="btGravar" runat="server" Text="Gravar" Icon="Disk">
                        <Listeners>
                             <Click Handler="Ext.net.DirectMethods.verificar();" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="Button4" runat="server" Text="Cancelar" Icon="Cancel">
                        <Listeners>
                            <Click Handler="#{WindowsRealizado}.hide();" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </Items>
        <Listeners>
            <Close Handler="Ext.net.DirectMethods.limparFinalizar();" />
            <Hide Handler="Ext.net.DirectMethods.limparFinalizar();" />
        </Listeners>
    </ext:Window>
    <ext:Window ID="WindowsVisualizar" runat="server" Icon="PageWhiteLightning" Title="Visualizar"
        Hidden="true" Modal="true" Width="450" AutoHeight="true" Resizable="false">
        <Items>
            <ext:FormPanel ID="FormPanel3" runat="server" Padding="5" Layout="Anchor" BodyStyle="background-color: transparent;"
                Header="false">
                <Items>
                    <ext:ComboBox ID="cbEmpresaVisualizar" runat="server" FieldLabel="Empresa" AllowBlank="false"
                        MsgTarget="Side" AnchorHorizontal="93%" Enabled="false" StoreID="strEmpresas" ValueField="idempresas"
                        DisplayField="empresa" />
                    <ext:TextField ID="txtContatoVisualizar" runat="server" FieldLabel="Contato" AllowBlank="false"
                        MsgTarget="Side" AnchorHorizontal="93%"  StoreID="strContato" ValueField="idcontatos"
                        DisplayField="contato"/>
                    <ext:TextField ID="txtEmail" runat="server" FieldLabel="Email" AllowBlank="false"
                        MsgTarget="Side" AnchorHorizontal="93%" />
                    <ext:TextField ID="txtTelefoneUsuarios" runat="server" FieldLabel="Telefone" AnchorHorizontal="93%"
                        AllowBlank="false" MsgTarget="Side">
                        <Plugins>
                            <ux:InputTextMask ID="InputTextMask1" runat="server" Mask="(99)9999-9999" />
                        </Plugins>
                    </ext:TextField>
                    <ext:TextArea ID="txtDescricaoVisualizar" runat="server" FieldLabel="Descrição Atividade" AllowBlank="false"
                        AnchorHorizontal="93%" MsgTarget="Side" />
                </Items>
                <Buttons>
                    <ext:Button ID="Button6" runat="server" Text="Cancelar" Icon="Cancel">
                        <Listeners>
                            <Click Handler="#{WindowsVisualizar}.hide();" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </Items>
        <Listeners>
            <Close Handler="Ext.net.DirectMethods.limparCampo();" />
            <Hide Handler="Ext.net.DirectMethods.limparCampo();" />
        </Listeners>
    </ext:Window>
      <ext:Hidden ID="hdfIdAtividade" runat="server" />
</asp:Content>
